import { createStore, applyMiddleware } from 'redux';
import reducer from './../3、reducers';
import thunk from 'redux-thunk';

// const reducer = (state = {
//   num: 1
// }, action) => {
//   switch (action.type) {
//     case 'ADD':
//       let { num } = state;
//       return {
//         num: num += 1
//       }
//   }

//   return state;
// }

// createStore 第二个参数用来接收中间件 applyMiddleware

const store = createStore(reducer, applyMiddleware(thunk));

// store.subscribe(() => {
//   let state = store.getState();
//   console.log(state);
// })

export default store;